import 'package:flutter/material.dart';

class HomePage extends StatefulWidget {
  // ignore: use_super_parameters
  const HomePage({Key? key}) : super(key: key);

  @override
  // ignore: library_private_types_in_public_api
  _HomePageState createState() => _HomePageState();
}

class _HomePageState extends State<HomePage> {
  // 状态
  int count = 0;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text(
          "计算器组件",
          style: TextStyle(color: Colors.black),
        ),
        backgroundColor: Colors.lightBlue,
      ),
      body: Center(
          child: Text(
        count.toString(),
        style: const TextStyle(color: Colors.lightGreen, fontSize: 40),
      )),
      floatingActionButton: FloatingActionButton(
        onPressed: () {
          // 更改状态 setState
          setState(() {
            count++;
          });
        },
        child: const Icon(Icons.add),
      ),
    );
  }
}
